<?php
// +----------------------------------------------------------------------
// | 后台用户管理
// +----------------------------------------------------------------------
namespace app\admin\controller\v1;
use app\admin\Adminbase;
use app\common\model\Shop as ShopModel;

class UserMemberCard extends Adminbase
{
	
    /**
     *  创建
     * /admin/v1/user_member_card/create
     * 需要登录
     * @is_need_login true
     * @method post
     */
    public function create(){
        try{
        	$param = $this->request->post();
        	$data = [];
          	for($i=0; $i< $param['num']; $i++){
          		$data[] = $param;
          	}
            $res = model("UserMemberCard")->allowField(true)->saveAll($data);
            return $this->ReSucess();   
        }catch(\Exception $e){
            return $this->ReError($e->getMessage());    
        }
    }

	 /**
     *  获取店铺列表
     * /admin/v1/user_member_card/create
     * 需要登录
     * @is_need_login true
     * @method post
     */
    public function xmlGetShopList(){
    	$param = $this->request->param();
    	$apply_shop_ids = json_decode($param['keyWord'],true)['filter'][0]['value'] ?: -1;
        try {
        	$data =  ShopModel::where('id','in',$apply_shop_ids)->field('id,name')->select();
            return $this->ReSucess([ 'total'=>count($data), 'data'=>$data ]);   
        } catch (Exception $e) {
            return $this->ReError($e->getMessage());    
        }
    }
	
}

